/**
 * 报销单据页面逻辑,只是报销单据加载此js
 */

function getDjlx(){  
	return "bx";
}
  
function initJkBx(){
	var headDs = getWebbxContext().getHeadDs();
    //摘要的參照框不需要派發事件
    var zyEle = getComponent('headTab_bxzb_form').getElement('zy_mc'); 
	if(zyEle != null){
		zyEle.innerProcessEnter = function(){
			var zy_mc = getComponent('headTab_bxzb_form').getElement('zy_mc').getValue();
			headDs.setValueAt(headDs.getSelectedIndex(),headDs.nameToIndex('zy'),zy_mc);
		}
    }
	
	//如果选中的tab页发生变换，需要更新按钮状态
	getComponent("bodyTab").afterActivedTabItemChange = function(currItem) {
		ButtonManager.getInstance().updateButtons();
	};
	
	/*报销标准注册*/
	var tmpArr = getWebbxContext().getHeadReimField();
	if(tmpArr != null){
		var headReimFields = tmpArr.split(",");
		for(var j = 0; j < headReimFields.length; j++) {
			eventChangeRegister(headReimFields[j],doHeadDataChange);
			eventChangeRegister(headReimFields[j],doBodyDataChange);
		}
	}
	
	var ybArr = ['ybje','ybye','hkybje','zfybje','cjkybje'];
	var bbArr = ['bbje','bbye','hkbbje','zfbbje','cjkbbje'];
	for(var i=0;i<5;i++){
		eventChangeRegister(ybArr[i],jeChange);
	}
	
	eventChangeRegister("bzbm",bzbmChange);
	eventChangeRegister("total",totalChange);
	eventChangeRegister("bbhl",bbhlChange);
	eventChangeRegister("szxmid",szxmidChange);
	eventChangeRegister("receiver",receiverChange);
	eventChangeRegister("jkbxr",jkbxrChange);
	exceHeadDsImpl(headDs);
	
	/**表体注册*/
	var busItemDs = getWebbxContext().getItemDs();
	var tmpBodyArr = getWebbxContext().getBodyReimField();
	if(tmpBodyArr != null){
		var bodyReimFields = tmpBodyArr.split(",");
		for(var j = 0; j < bodyReimFields.length; j++) {
			eventChangeRegister(bodyReimFields[j],doBodyDataChange);
		}
	}
	eventChangeRegister("amout",amountBodyChange);
	eventChangeRegister("szxmid",szxmidBodyChange);
	
};

/*币种*/
function bzbmChange(event){
	if(event.currentValue == event.oldValue)
		return;
	window.PageCtx.updatePageStatus("cjk",true);
	//window.isNewCjkDialog = true;//收款人字段变化，则重新加载冲借款
	var headDs = window.PageCtx.getHeadDs();
	reset4Bzbm(headDs, event.currentValue, "bx");
	//如果是还款单，币种改变，则清空表体、表头金额，重新选择
	var type = getParameter(WebbxConstant.BX_HK_PARAM);
	if(type != null && type == 'hk'){
		//window.isNewCjkDialog = true;
		var cDs = window.PageCtx.getCxDs();
		cDs.deleteRows(-1);
		var arr = ['ybye','hkybje','zfybje','cjkybje'];
		for(var ii=0; ii<arr.length; ii++)
			headDs.setValueAt(0,headDs.nameToIndex(arr[ii]),0);
	}
}
/*合计*/
function totalChange(event){
	if(window.PageCtx.getPageStatusById("copy") || window.PageCtx.getPageStatusById("refresh")){//如果是刷新操作后，则return 
		return; 
	}
	if(event.currentValue == null || event.currentValue == '')
		return;
	var headDs = window.PageCtx.getHeadDs();
	if(event.currentValue != 0){
		headDs.setValueAt(event.cellRowIndex, headDs.nameToIndex('ybje'),$f(event.currentValue));
	}
}
/*本币汇率*/
function bbhlChange(event){
	
}
/*收支项目*/
function szxmidChange(event){
	
}
/*金额*/
function jeChange(event){
	
}
/*收款人*/
function receiverChange(event){
	
}
/*借款报销人*/
function jkbxrChange(event){
	
}
/*表头标准*/
function doHeadDataChange(event){
	
}
/*表体*/
function doBodyDataChange(event){
	
}

/*表体金额*/
function amountBodyChange(event){
	
}
/*表体收支项目*/
function szxmidBodyChange(event){
	
}

